#! python
# -*- coding: utf-8 -*-
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from render import get_svg


def http_content():
    text_html = '''<html>
    <body style='background: black; color: white; width:3800px; height: 2500px'>

    <h1>Mine it!</h1> <br>

    ''' + get_svg(0) + '</body></html>'''

    return text_html
    # 0 - Normal
    # 1 - Dark
    # 2 - Chrome vs Ferrum
    # 3 - Silicone map


class HandlerRequest(BaseHTTPRequestHandler):

    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-type','text/html')
        self.end_headers()

        if self.requestline == u"GET / HTTP/1.1":
            self.wfile.write(http_content())


def main():
    try:
        # import noise_generator
        # noise_generator.refresh_map_generator()
        # noise_generator.refresh_map_generator()
        # noise_generator.refresh_map_generator()
        # noise_generator.refresh_map_generator()

        server = HTTPServer(('192.168.1.5', 8080), HandlerRequest)
        print 'started httpserver...'
        server.serve_forever()

    except KeyboardInterrupt:
        print '^C received, shutting down server'
        server.socket.close()

if __name__ == '__main__':
    main()